﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using uAccess;
using WebApi.Models;

namespace Admin
{
    public class AdminRefund
    { 
        //得到退款信息列表
        public static JArray FindRefund()
        {
            JArray refundsList = new JArray();
            var op = new uAccess<Returns>("dbConnect"); //数据库连接对象
            var customers_str = JsonConvert.SerializeObject(op.GetAll(c=>c.Ret_Check==0));
            refundsList = JArray.Parse(customers_str);
            return refundsList;
        }

        public static void RefundAgree(String odr_id)
        {
            JArray refundsList = new JArray();
            var op = new uAccess<Returns>("dbConnect"); //数据库连接对象
            odr_id=odr_id.Substring(1, odr_id.Length - 2);
            var order = op.GetFirst(c => c.Odr_Id == odr_id);
            if (order.Ret_Check == 0)
            {
                order.Ret_Check = 1;
            }
            op.Update(order);
            //var customers_str = JsonConvert.SerializeObject(op.GetAll(c => c.Ret_Check == 0));
            //refundsList = JArray.Parse(customers_str);
            //return refundsList;
        }
    }
}